]> git.r.bdr.sh - rbdr/super-polarity/blame_incremental - Super Polarity/SuperPolarity.cs
Chubas's House happened.
[rbdr/super-polarity] / Super Polarity / SuperPolarity.cs
... / ...
CommitLineData
1#region Using Statements
2using System;
3using System.Collections.Generic;
4using Microsoft.Xna.Framework;
5using Microsoft.Xna.Framework.Content;
6using Microsoft.Xna.Framework.Graphics;
7using Microsoft.Xna.Framework.Input;
8using Microsoft.Xna.Framework.Storage;
9using Microsoft.Xna.Framework.GamerServices;
10using SuperPolarity;
11#endregion
12
13namespace SuperPolarity
14{
15 /// <summary>
16 /// This is the main type for your game
17 /// </summary>
18 public class SuperPolarity : Game
19 {
20 public static GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
22
23 // Input Handler
24 KeyboardState currentKeyboardState;
25 GamePadState currentGamePadState;
26
27 MainShip player;
28
29 public SuperPolarity()
30 : base()
31 {
32 SuperPolarity.graphics = new GraphicsDeviceManager(this);
33 SuperPolarity.graphics.PreferMultiSampling = true;
34 Content.RootDirectory = "Content";
35 }
36
37 /// <summary>
38 /// Allows the game to perform any initialization it needs to before starting to run.
39 /// This is where it can query for any required services and load any non-graphic
40 /// related content. Calling base.Initialize will enumerate through any components
41 /// and initialize them as well.
42 /// </summary>
43 protected override void Initialize()
44 {
45 player = new MainShip();
46
47 base.Initialize();
48 }
49
50 /// <summary>
51 /// LoadContent will be called once per game and is the place to load
52 /// all of your content.
53 /// </summary>
54 protected override void LoadContent()
55 {
56 // Create a new SpriteBatch, which can be used to draw textures.
57 spriteBatch = new SpriteBatch(GraphicsDevice);
58
59 Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
60
61 player.Initialize(Content, Content.Load<Texture2D>("Graphics\\main-ship"), playerPosition);
62 }
63
64 /// <summary>
65 /// UnloadContent will be called once per game and is the place to unload
66 /// all content.
67 /// </summary>
68 protected override void UnloadContent()
69 {
70 // TODO: Unload any non ContentManager content here
71 }
72
73 /// <summary>
74 /// Allows the game to run logic such as updating the world,
75 /// checking for collisions, gathering input, and playing audio.
76 /// </summary>
77 /// <param name="gameTime">Provides a snapshot of timing values.</param>
78 protected override void Update(GameTime gameTime)
79 {
80 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
81 Exit();
82
83 // TODO: Add your update logic here
84
85 InputController.UpdateInput();
86 player.Update(gameTime);
87
88 base.Update(gameTime);
89 }
90
91 /// <summary>
92 /// This is called when the game should draw itself.
93 /// </summary>
94 /// <param name="gameTime">Provides a snapshot of timing values.</param>
95 protected override void Draw(GameTime gameTime)
96 {
97 GraphicsDevice.Clear(Color.White);
98
99 spriteBatch.Begin();
100
101 player.Draw(spriteBatch);
102
103 spriteBatch.End();
104
105 base.Draw(gameTime);
106 }
107 }
108}